import axios from 'axios';
import queryString from 'qs';
import { downloadFile } from '@util/download-file';

export const addOrganization = body => {
  return axios.post('/api/system/addOrganization', body);
};

export const updateOrganization = body => {
  return axios.post('/api/system/updateOrganization', body);
};

export const deleteOrganization = id => {
  return axios.post('/api/system/deleteOrganization', { id });
};

export const getOrganization = params => {
  return axios.get(
    `/api/system/getOrganization?${queryString.stringify(params, { indices: false })}`
  );
};

export const getAllOrganization = () => {
  return axios.get('/api/system/getAllOrganization');
};

export const addStaffToOrg = body => {
  return axios.post('/api/system/addStaff', body);
};

export const getStaffList = params => {
  return axios.get(`/api/system/getStaffList?${queryString.stringify(params, { indices: false })}`);
};

export const delStaff = body => {
  return axios.post('/api/system/delStaff', body);
};

export const updateStaff = body => {
  return axios.post('/api/system/updateStaff', body);
};

export const batchUpdateStaff = body => {
  return axios.post('/api/system/batchUpdateStaff', body);
};

export const batchAddOrgUpload = body => {
  return axios.post('/api/system/batchAddOrg', body);
};

export const getFailFileDownload = (type, fileName) => {
  // return axios.get(`/api/system/download-failed-excel?type=${type}&filename=${fileName}`)
  return downloadFile('get', `/api/system/download-failed-excel?type=${type}&filename=${fileName}`);
};

export const batchAddStaffUpload = body => {
  return axios.post('/api/system/batchAddStaff', body);
};
